#!/bin/sh

APP_CONFIG_FILE=app.config

WAP_HW_INFO=../wap.info

if [ ! -f $APP_CONFIG_FILE ]; then
        echo "Can't find $APP_CONFIG_FILE This Update zip is Bad"
        exit 1
fi

if [ ! -f $WAP_HW_INFO ]; then
        echo "Can't find $WAP_HW_INFO This Update zip is Bad"
        #exit 1
fi

echo "get app.config ..."

APP_HW_V=`awk '{if ($1=="WAP800_HW_V") {print $2}}' $APP_CONFIG_FILE`

APP_SW_V=`awk '{if ($1=="WAP800_SW_V") {print $2}}' $APP_CONFIG_FILE`

APP_OLD_NAME=`awk '{if ($1=="WAP800_SW_OLDNAME") {print $2}}' $APP_CONFIG_FILE`

APP_NEW_NAME=`awk '{if ($1=="WAP800_SW_NEW_NAME") {print $2}}' $APP_CONFIG_FILE`

echo "$APP_HW_V , $APP_SW_V , $APP_OLD_NAME , $APP_NEW_NAME"

WAP_HW_V=`awk '{if ($1=="WAP800_HW_V") {print $2}}' $WAP_HW_INFO`

if [ $APP_HW_V == $WAP_HW_V ];then
	echo "This WAP Hardware Versions is $WAP_HW_V"
	mv ../wap800_app  ../recycle/
	cp wap800_app ../
	echo "update finsh ...."
fi

exit 0
